package com.gp.testonline.service.impl;

import com.gp.testonline.dao.ExampaperMapper;
import com.gp.testonline.eo.ExampaperEOPage;
import com.gp.testonline.model.Exampaper;
import com.gp.testonline.service.ExampaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*
 *实现业务及流程接口当中的内容
 */
@Service
public class ExampaperServiceImpl implements ExampaperService {
    @Autowired
    private ExampaperMapper exampaperMapper;

    @Override
    public int InsertExampaper(Exampaper exampaper) {
        int isInsert=0;
        /*1 没有相关业务流程的判断*/
        try{
            isInsert=exampaperMapper.insertExampaper(exampaper);
        }catch (Exception e){
            isInsert=-1;
            //打印时报错的情况
            System.out.println("添加信息时执行sql报错的原因为："+e.getMessage());
        }
        return isInsert;
    }

    @Override
    public int UpdateExampaper(Exampaper exampaper) {
        int isUpdate=0;
        /*1 没有相关业务流程的判断*/
        try{
            isUpdate=exampaperMapper.updateExampaper(exampaper);
        }catch (Exception e){
            isUpdate=-1;
            //打印时报错的情况
            System.out.println("更新信息时执行sql报错的原因为："+e.getMessage());
        }
        return isUpdate;
    }

    @Override
    public int DeleteExampaper(int epid) {
        int isDelete=0;
        /*1 没有相关业务流程的判断*/
        try{
            isDelete=exampaperMapper.deleteExampaper(epid);
        }catch (Exception e){
            isDelete=-1;
            //打印时报错的情况
            System.out.println("删除信息时执行sql报错的原因为："+e.getMessage());
        }
        return isDelete;
    }

    @Override
    public List<ExampaperEOPage> getExampaperAll(ExampaperEOPage exampaperEOPage) {
        List<ExampaperEOPage> listExampaperEo=exampaperMapper.getExampaperAll(exampaperEOPage);
        return listExampaperEo;
    }
}
